//console.log('axios: ', axios)
//console.log('ElementUI: ', Element)
//Vue.use(Element)
const vue = new Vue({
  el: '#app',
  data: {
    appName: undefined,
    form: {
        wifiEnable: false
    }
  },
  created() {
      // `this` 指向 vm 实例
      console.log('created')
      this.init()
  },
  methods: {
    init() {
        console.log('init')
        axios.get('./wifi').then(res => {
            console.log('res ', res)
            this.form.wifiEnable = res.data
        })
        .catch(err => {
            console.log('error ', err)

        })
    },
    buttonWifi() {
        const wifiEnable = this.form.wifiEnable
        console.log('buttonWifi wifiEnable: ' + wifiEnable)
//        const param = {
//            params: {
//                action: wifiEnable
//            }
//        }
//        console.log('buttonWifi param: ' + JSON.stringify(param))
        axios.post(`./wifi?action=${wifiEnable}`).then(res => {
            console.log('res ', res)
            alert('OK')
        })
        .catch(err => {
            console.log('error ', err)

        })    }
  }
})
